<HTML>
<HEAD>
    <TITLE>后台管理系统</TITLE>
    <META http-equiv=Content-Type content="text/html; charset=utf-8">
    <META content="Microsoft FrontPage 4.0" name=GENERATOR>
    <script src="__FINANCE__/Scripts/jquery.js" charset="utf-8"></script>
    <script src="__FINANCE__/Scripts/watermarker.js" charset="utf-8"></script>
    <link href="__FINANCE__/layui/css/layui.css" rel='stylesheet' type='text/css'/>
    <script src="__FINANCE__/layui/layui.js" charset="utf-8"></script>
    <title>111</title>
    <!--<script src="__FINANCE__/layer/layer.js" charset="utf-8"></script>-->

    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</HEAD>
<style>
    @page {
        /*size: landscape;  !* auto is the initial value *!*/
        margin: 0mm 10mm 0mm 10mm
    }

</style>
<style>
    /* 偶数行背景色 */
    .layui-table[lay-even] tr:nth-child(even) {
        /* background-color: #aaffaa; */
        background-color: #eeffee;
    }

    /* 鼠标指向表格时,奇数行背景颜色 */
    .layui-table tbody tr:hover,.layui-table-hover {
        background-color: #abd1f9;
    }

    /*!* 表格头部工具栏背景色 *!*/
    /*.layui-table-tool {*/
        /*background-color: #eeffee;*/
    /*}*/

    /* 表格头部背景色 */
    /*th {*/
        /*background-color: #359f6a; !* MediumSeaGreen *!*/
        /*color: #fff;*/
        /*font-weight: bold*/
    /*}*/
</style>
<body>
{if session('user_name') == 'admin' }
<!--<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">-->
    <!--<tr>-->

        <!--<td width="68%" background="__FINANCE__/Images/b2.jpg">-->
            <!--<table width="124" border="0" align="left" cellpadding="0" cellspacing="0">-->
                <!--<tr>-->
                    <!--<td width="20" align="left"><img src="__FINANCE__/Picture/tz.gif" width="10" height="16"/></td>-->
                    <!--<td width="104" align="left" class="biao">查询条件</td>-->
                <!--</tr>-->
            <!--</table>-->
        <!--</td>-->

    <!--</tr>-->
<!--</table>-->
<!--<blockquote class="layui-elem-quote layui-quote-nm" style="margin-bottom: 0px;padding:0px;padding-top: 10px">-->
    <!--<div class="layui-form-item">-->
        <!--<form class="layui-form" id="form1" name="form1" method="get" action="">-->
            <!--<table width="100%" border="0" cellspacing="1" cellpadding="3">-->
                <!--<tr align="center">-->
                    <!--<td align="center" width="2%">姓名：</td>-->
                    <!--<td width="5%">-->
                        <!--<div class="layui-input-inline">-->
                            <!--<input type="tel" name="name" id="name" autocomplete="off"-->
                                   <!--class="layui-input">-->
                        <!--</div>-->
                    <!--<td align="center" width="3%">身份证号：</td>-->
                    <!--<td align="center" width="10%">-->
                        <!--<input type="text" name="card_num" id="card_num"  placeholder="" autocomplete="off"-->
                               <!--class="layui-input">-->
                    <!--</td>-->
                    <!--<td width="10%">-->
                        <!--<div class="layui-input-block">-->
                            <!--<button type="button" id="search-input" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="demo1">-->
                                <!--搜索-->
                            <!--</button>-->
                            <!--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                        <!--</div>-->
                    <!--</td>-->
                <!--</tr>-->
            <!--</table>-->
        <!--</form>-->
    <!--</div>-->
<!--</blockquote>-->
{/if}
<!--<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">-->
    <!--<tr>-->
        <!--<td width="68%" background="__FINANCE__/Images/b2.jpg">-->
            <!--<table width="124" border="0" align="left" cellpadding="0" cellspacing="0">-->
                <!--<tr>-->
                    <!--<td width="20" align="left"><img src="__FINANCE__/Picture/tz.gif" width="10" height="16"/></td>-->
                    <!--<td width="104" align="left" class="biao">数据列表</td>-->
                <!--</tr>-->
            <!--</table>-->
        <!--</td>-->
    <!--</tr>-->
<!--</table>-->
<table class="layui-hide" id="expense_list" lay-filter="expense_list"></table>
<script type="text/html" id="expense_list_toolbar">
    <div class="layui-btn-container">

        <button type="button"  class="layui-btn" id="addExpense" lay-event="addExpense"><i class="layui-icon">&#xe654;</i>添加</button>
        <button type="button" class="layui-btn layui-btn-normal" id="editUser" lay-event="editExpense"><i class="layui-icon">&#xe642;</i>编辑</button>
        <button type="button" class="layui-btn layui-btn-danger" id="deletes" lay-event="deletes"><i class="layui-icon">&#xe640;</i>删除</button>

    </div>
</script>


<script>
    //点击放大图片
    $(function(){
        $(document).on('click', '.pimg', function(){
            var _this = $(this);
            layer.open({
                type: 1,
                title: '图片详情',
                area: ['1000px', '500px'], //宽高
                content:"<img width='1000px' src="+  _this.attr('src') +">"
            });
        });


        $(document).on('click', '.show', function(){
            var _this = $(this);
            var checkId = _this.data('id');
//            layer.open({
//                type: 2,
//                area: ['aito', '600px'], //宽高
//                content: '{:url("/finance/Expense/showExpense")}' + '?id=' +  checkId//这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
//            });
            $.ajax({
                url: '{:url("/finance/Expense/showExpense")}',
                type: 'get',
                data:{id: checkId},
                dataType: 'html',
                beforeSend: function () {
                    layer.load(2);
                },
                complete: function () {
                    layer.closeAll('loading');
                },
                success: function (res) {
                    layer.open({
                        type: 1,
                        title:'详情',
                        skin: 'layui-layer-rim', //加上边框
                        area: ['auto', '500px'], //宽高
                        content: res,
                        cancel: function(index, layero){
                            // tableIns.reload({
                            //     where: {}
                            //     , page: {
                            //         curr: 1 //重新从第 1 页开始
                            //     }
                            // });
                            layer.close(index);
                            return false;
                        },
                        end:function(){
                            // tableIns.reload({
                            //     where: {}
                            //     , page: {
                            //         curr: 1 //重新从第 1 页开始
                            //     }
                            // });
                            // var _body = window.parent;
                            // var _iframe1=_body.document.getElementById('leftMenu');
                            // window.onbeforeunload=function(){};
                            // _iframe1.contentWindow.location.reload(true);

                            // var  test = parent.frames("leftMenu").document;

                            $.ajax({
                                url: '{:url("/finance/Expense/getNoReadyCount")}',
                                type: 'get',
                                dataType: 'json',
                                success: function (res) {
                                    // console.log(res);
                                    parent.window.frames["leftMenu"].document.getElementById("count_num").innerHTML = res.data.count;
                                    return false;
                                }
                            });
                        }
                    });
                    return false;
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    layer.alert('网络失败，请联系管理员', {icon: 2});
                }
            });

        });
    });
</script>

<script>
    watermark({watermark_txt:'新乡市纪委监委财务管理'});
    layui.use(['table', 'upload', 'laydate'], function () {
        var table = layui.table
            ,$ = layui.jquery
            , layer = layui.layer
            , upload = layui.upload
            ,laydate = layui.laydate;


        var tableIns = table.render({
            elem: '#expense_list'
            , url: '{:url("/finance/Expense/ajaxExpenseChaXun")}'
            , toolbar: '#expense_list_toolbar'
            ,defaultToolbar: ['filter']
            , title: '用户数据表'
            , totalRow: true
            ,height:500
            ,limit:15
            ,limits:[15, 30, 45, 60, 80,100]
            , cols: [[
                {type: 'checkbox', fixed: 'left'}
//                , {field: 'id', title: 'id', width: 60, fixed: 'left', sort: true, totalRowText: '合计'}
//                , {field: 'fill_from', title: '填表人', width: 80}
                , {field: 'fill_from', title: '填表人',fixed: 'left',align: 'center', width: 80,templet:function (d) {
                        return '<a style="color: #0a6aa1" data-id='+ d.id +' href="javascript:;" class="show" >'+ d.fill_from +'</a>'
                    }}
                , {field: 'number_people', title: '出差人数',fixed: 'left',align: 'center', width: 100,}
                , {field: 'fill_time', title: '填表时间', align: 'center', width: 120,}
                , {field: 'eat_subsidy_day', title: '伙食补助/天', align: 'center', width: 120,}
                , {field: 'eat_subsidy_standard', title: '伙食补助/标准', align: 'center', width: 120,}
                , {field: 'eat_subsidy_money', title: '伙食补助/金额', align: 'center', width: 120,}
                , {field: 'stay_day', title: '住宿费/天', align: 'center', width: 120,}
                , {field: 'stay_standard', title: '住宿费/标准', align: 'center', width: 120,}
                , {field: 'stay_money', title: '住宿费/金额', align: 'center', width: 120,}
                , {field: 'traffic_kind', title: '车船费/种类', align: 'center', width: 120,}
                , {field: 'traffic_money', title: '车船费/金额', align: 'center',width: 120,}
                , {field: 'sleeper_standard', title: '卧铺补助/标准', align: 'center', width: 120,}
                , {field: 'sleeper_money', title: '卧铺补助/金额', align: 'center', width: 120,}
                , {field: 'city_traffic_day', title: '市内交通费/天数', align: 'center', width: 140,}
                , {field: 'city_traffic_standard', title: '市内交通费/标准', align: 'center', width: 140,}
                , {field: 'road_bridge_money', title: '路桥费', align: 'center', width: 80,}
                , {field: 'other', title: '其他', align: 'center', width: 80,}
                , {field: 'business_people', title: '出差人', align: 'center', width: 80,}
                , {field: 'brancher_leader', title: '分管领导', align: 'center', width: 80,}
                , {field: 'office_director', title: '办公室主任', align: 'center', width: 80,}
                , {field: 'secretary', title: '书记', align: 'center', width: 80,}
                , {field: 'examine_leader', title: '审批领导', align: 'center', width: 80,}
                , {field: 'total', title: '合计', align: 'center', width: 100,}
                , {field: 'start_time', title: '开始时间', align: 'center',fixed: 'right', width: 120,}
                , {field: 'end_time', title: '结束时间', align: 'center',fixed: 'right', width: 120,}
                , {field: 'file_id', title: '源文件', align: 'center', width: 80,fixed: 'right',templet:function (d) {
                        return '<img class="pimg" style="width: 60px;height:40px" src=' + d.file_id  + '></img>'
                    }}
//                , {field: 'level_of_wages', title: '应发工资', width: 150, totalRow: true}
//                , {field: 'net_payroll', title: '实发工资', width: 150, totalRow: true}
            ]]
            , page: true
        });
        //工具栏事件
        table.on('toolbar(expense_list)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'addExpense':
                    $.ajax({
                        url: '{:url("/finance/Expense/addExpense")}',
                        type: 'get',
                        dataType: 'html',
                        beforeSend: function () {
                            layer.load(2);
                        },
                        complete: function () {
                            layer.closeAll('loading');
                        },
                        success: function (res) {
                            layer.open({
                                type: 1,
                                title:'创建报销单',
                                skin: 'layui-layer-rim', //加上边框
                                area: ['auto', '500px'], //宽高
                                shadeClose: true,
                                content: res,
                                cancel: function(index, layero){
                                    tableIns.reload({
                                        where: {}
                                        , page: {
                                            curr: 1 //重新从第 1 页开始
                                        }
                                    });
                                    layer.close(index)
                                    return false;
                                },
                                end:function(){
                                    tableIns.reload({
                                        where: {}
                                        , page: {
                                            curr: 1 //重新从第 1 页开始
                                        }
                                    });
                                }
                            });
                            return false;
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert('网络失败，请联系管理员', {icon: 2});
                        }
                    });
                    break;
                case 'editExpense': //导出文件
                    var data = checkStatus.data;
                    if(data.length == 0){
                          layer.msg('请选择编辑的记录', {icon: 5}); return false;
                    }
                    if(data.length > 1){
                        layer.msg('只能编辑一条信息', {icon: 5}); return false;
                    }
                    var checkId = '';　//创建一个数组
                    $.each(data,function(k,value){
                        checkId += value.id ;
                    });
                    $.ajax({
                        url: '{:url("/finance/Expense/editExpense")}',
                        type: 'get',
                        data:{id: checkId},
                        dataType: 'html',
                        beforeSend: function () {
                            layer.load(2);
                        },
                        complete: function () {
                            layer.closeAll('loading');
                        },
                        success: function (res) {
                            layer.open({
                                type: 1,
                                title:'编辑',
                                skin: 'layui-layer-rim', //加上边框
                                area: ['auto', '500px'], //宽高
                                content: res,
                                cancel: function(index, layero){
                                    tableIns.reload({
                                        where: {}
                                        , page: {
                                            curr: 1 //重新从第 1 页开始
                                        }
                                    });
                                    layer.close(index)
                                    return false;
                                },
                                end:function(){
                                    tableIns.reload({
                                        where: {}
                                        , page: {
                                            curr: 1 //重新从第 1 页开始
                                        }
                                    });
                                }
                            });
                            return false;
                        },
                        error: function (XMLHttpRequest, textStatus, errorThrown) {
                            layer.alert('网络失败，请联系管理员', {icon: 2});
                        }
                    });
                    break;
                case 'deletes':
                    var data = checkStatus.data;
                    if(data.length == 0){
                        layer.msg('请选择删除的记录', {icon: 5}); return false;
                    }
                    layer.confirm('确定要删除吗?', {
                        btn: ['确定','取消'] //按钮
                    }, function(){
                        //获取选中的ID
                        var checkIdS = '';　//创建一个数组
                        $.each(data,function(k,value){
                            checkIdS += value.id + ',';
                        });

                        $.ajax({
                            url: '{:url("/finance/Expense/delete")}',
                            type: 'post',
                            dataType: 'json',
                            data: {checkIdS: checkIdS},
                            cache: false,
                            async: true,
                            beforeSend: function () {
                                layer.load(2);
                            },
                            complete: function () {
                                layer.closeAll('loading');
                            },
                            success: function (res) {
                                if(res.code == 1){
                                    layer.msg('删除成功', {icon: 1});
                                    tableIns.reload({
                                        where: {}
                                        , page: {
                                            curr: 1 //重新从第 1 页开始
                                        }
                                    });
                                    return false;
                                }
                                layer.alert('删除失败', {icon: 2}); return false;
                            },
                            error: function (XMLHttpRequest, textStatus, errorThrown) {
                                layer.alert('网络失败，请联系管理员', {icon: 2});
                            }
                        });


                    }, function(){
//                        layer.msg('', {
//                            time: 20000, //20s后自动关闭
//                            btn: ['明白了', '知道了']
//                        });
                    });
                    break;
            }
        });
        //搜索重载表格
        $('#search-input').click(function () {
            var name = $('#name').val();
            var card_num = $('#card_num').val();
            tableIns.reload({
                where: { //设定异步数据接口的额外参数，任意设
                    name: name
                    , card_num: card_num
                }
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });
    });
</script>
</body>
</HTML>